package com.wyh.controller.groupOne.customer;

import com.wyh.common.enums.ResultCodeEnum;
import com.wyh.common.result.Result;
import com.wyh.domain.vo.groupOne.customer.Feenotificationconfiguration;
import com.wyh.service.groupOne.customer.MasterDataFeenotificationconfigurationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "通知配置API")
@RestController
@RequestMapping("/feenotificationconfiguration")
public class FeenotificationconfigurationController {

    @Autowired
    private MasterDataFeenotificationconfigurationService masterDataFeenotificationconfigurationService;

    /**
     * 修改通知配置
     * @param feenotificationconfiguration
     * @return
     */
    @ApiOperation("修改通知配置")
    @PostMapping("update")
    public Result update(@RequestBody Feenotificationconfiguration feenotificationconfiguration) {
        if (feenotificationconfiguration.getId() != null) {
            masterDataFeenotificationconfigurationService.update(feenotificationconfiguration);
            return Result.success();
        }
        return Result.error(ResultCodeEnum.ORGANIZATION_UPDATE_ERROR);
    }

    /**
     * 添加通知配置
     * @param feenotificationconfiguration
     * @return
     */
    @ApiOperation("添加通知配置")
    @PostMapping("add")
    public Result insert(@RequestBody Feenotificationconfiguration feenotificationconfiguration) {
        if (feenotificationconfiguration.getUserid() != null) {
            masterDataFeenotificationconfigurationService.insert(feenotificationconfiguration);
            return Result.success();
        }
        return Result.error(ResultCodeEnum.OPERATION_AUTHORITY_ERROR);
    }

    /**
     * 查询通知配置
     * @param id
     * @return
     */
    @ApiOperation("查询通知配置")
    @ApiImplicitParam(name = "id",value = "客户id",required = true)
    @GetMapping("selectById/{id}")
    public Result selectById(@PathVariable Integer id) {
        Feenotificationconfiguration feenotificationconfiguration = masterDataFeenotificationconfigurationService.selectById(id);
        return Result.success(feenotificationconfiguration);
    }
}
